import { IPSControl } from '../ipscontrol';
import { IPSSysPanelControl } from './ipssys-panel-control';
import { PSSysPanelItemImpl } from './pssys-panel-item-impl';

export class PSSysPanelControlImpl extends PSSysPanelItemImpl implements IPSSysPanelControl {
  protected pscontrol: IPSControl | null = null;

  getPSControl(): IPSControl | null {
    if (this.pscontrol != null) return this.pscontrol;
    const value = this.M.getPSControl;
    if (value == null) {
      return null;
    }
    this.pscontrol = this.getPSModel4('control.IPSControl', value, 'getPSControl') as IPSControl;
    return this.pscontrol;
  }

  get psControl(): IPSControl | null {
    return this.getPSControl();
  }

  getPSControlMust(): IPSControl {
    const value = this.getPSControl();
    if (value == null) {
      throw new Error('未指定部件对象');
    }
    return value;
  }

  get viewFieldName(): string {
    return this.M.viewFieldName;
  }

  get cls(): string {
    return 'PSSysPanelControlImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.panel.IPSPanelControl' || cls == 'control.panel.IPSSysPanelControl') return true;
    return super.instanceof(cls);
  }
}
